/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.brands.application.ics.factory;

import br.com.brands.application.ics.dao.BrandsDAOImpl;
import br.com.brands.application.ics.dao.CategoryDAOImpl;
import br.com.brands.application.ics.dao.ProductsDAOImpl;
import br.com.brands.application.ics.factory.intf.DAOFactoryIntf;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;

/**
 *
 * @author ppacheco
 */
public class DAOFactory implements DAOFactoryIntf {

    /**
     *
     */
    private static final long serialVersionUID = 6525022496191939686L;
    private static DAOFactory instance = null;
    private static final Logger log = Logger.getLogger(DAOFactory.class
            .getName());

    public DAOFactory() {
        log.log(Level.INFO, "Loading DAOFactory");
    }

    @SuppressWarnings("rawtypes")
    @Override
    public BrandsDAOImpl getBrandsDAOImpl() {
        BrandsDAOImpl brandsDAOImpl = new BrandsDAOImpl();
        return brandsDAOImpl;
    }

    @SuppressWarnings("rawtypes")
    @Override
    public CategoryDAOImpl getCategoryDAOImpl() {
        CategoryDAOImpl categoryDAOImpl = new CategoryDAOImpl();
        return categoryDAOImpl;
    }

    @SuppressWarnings("rawtypes")
    @Override
    public ProductsDAOImpl getProductsDAOImpl() {
        ProductsDAOImpl productsDAOImpl = new ProductsDAOImpl();
        return productsDAOImpl;
    }

    /**
     *
     * @return @throws InstantiationException
     */
    public static DAOFactory getInstance() throws InstantiationException {
        try {
            if (instance == null) {
                instance = new DAOFactory();
            }
        } catch (Exception e) {
            log.log(Level.DEBUG, e.getMessage(), e);
        }
        return instance;
    }
}
